﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Module;
using DLL;

namespace BLL
{
    public class BUserPost
    {
        #region 字段

        private DUserPost APP = new DUserPost();//数据操作对象
        private static BUserPost instance;

        #endregion

        #region 公共接口
        /// <summary>
        /// 取得
        /// </summary>
        /// <returns>BUserPost对象</returns>
        public static BUserPost getInstance()
        {
            if (instance == null)
            {
                instance = new BUserPost();
            }
            return instance;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userPostInfo"></param>
        /// <returns></returns>
        public bool Insert(UserPostInfo userPostInfo)
        {
            if (userPostInfo == null || userPostInfo.UserPostId == 0)
                return false;
            return APP.Insert(userPostInfo);

        }


        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="userPostInfo"></param>
        /// <returns></returns>
        public bool Update(UserPostInfo userPostInfo)
        {
            if (userPostInfo == null || userPostInfo.UserPostId == 0)
                return false;
            return APP.Update(userPostInfo);
        }
        /// <summary>
        /// 根据文章Id删除所有回复
        /// </summary>
        /// <param name="userPaperId"></param>
        /// <returns></returns>
        public int DeleteByUserPagerId(long userPaperId)
        {
            if (userPaperId == 0 || userPaperId.ToString().Length != 18)
                return 0;
            return APP.DeleteByPagerId(userPaperId);
        }
        /// <summary>
        /// 删除单条回复
        /// </summary>
        /// <param name="postId"></param>
        /// <returns></returns>
        public int Delete(long postId)
        {
            if (postId == 0 || postId.ToString().Length != 18)
                return 0;
            return APP.Delete(postId);
        }

        /// <summary>
        /// 根据PaperId获取所有回复
        /// </summary>
        /// <param name="userPaperId"></param>
        /// <returns></returns>
        public List<UserPostInfo> GetAllPostByUserPaperId(long userPaperId)
        {
            if (userPaperId == 0 || userPaperId.ToString().Length != 18)
                return null;
            return APP.GetAllPostByPaperId(userPaperId);

        }
         /// <summary>
        /// 根据PostId获取单条Comment
        /// </summary>
        /// <param name="userPostId"></param>
        /// <returns></returns>
        public UserPostInfo GetPostByUserPostId(long userPostId)
        {
            if (userPostId == 0 || userPostId.ToString().Length != 18)
                return null;
             return APP.GetPostByUserPostId(userPostId);
        }
        #endregion
    }
}
